package cn.com.dhee.springcloudtraining.user.fallback;

import cn.com.dhee.springcloudtraining.order.api.qo.OrderQO;
import cn.com.dhee.springcloudtraining.order.api.vo.OrderVO;
import cn.com.dhee.springcloudtraining.user.feign.OrderFeign;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;

/**
 * @author ralphwong
 */
@Component
public class OrderFeignFallback implements FallbackFactory<OrderFeign> {
    @Override
    public OrderFeign create(Throwable throwable) {
        return new OrderFeign() {
            @Override
            public OrderVO info(String orderId) {
                OrderVO vo = new OrderVO();
                vo.setRemark("目标服务调用失败，服务降级");
                return vo;
            }

            @Override
            public List<OrderVO> select(OrderQO qo) throws InterruptedException {
                return new ArrayList<>();
            }
        };
    }
}